/**
 * Copyright (C) 2011 KingCore Science & Technology CO,.LTD. All rights reserved.
 * XNS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/**
 * Copyright (C) 2002-2011 WUZEWEN. All rights reserved.
 * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 * This software is the confidential and proprietary information of
 * WuZeven, Personal. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with WuZeven.
 */

package com.kingcore.director.base.ui;

import java.util.Observable;
import java.util.Observer;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.border.BevelBorder;

import com.kingcore.director.core.ui.ButtonAction;
import com.kingcore.director.main.MainFrame;

/**
 * <p>Director 系统所有 ToolBar的基类，主要是生成界面，具体的执行在对应的 Windows(JPane)中。</p>
 * @author Zeven on 2011-4-8
 * @version	1.0
 * @see		Object#equals(java.lang.Object)
 * @since	JDK5
 */

public class DirectorToolBar extends JToolBar implements Observer {

	public DirectorToolBar(String name) {
		super(name);
		// TODO Auto-generated constructor stub
	}
 
	public DirectorToolBar(String string, DirectorPanel directorPanel) {
		super(string);
		 
		addButtons(directorPanel);   //这两个方法必须分开，供子类调用添加新的按钮
		initBarStatus();
	}
	
	protected void initBarStatus() {
		 this.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
		 this.setOrientation(JToolBar.HORIZONTAL);
//		 this.addComponentListener(new java.awt.event.ComponentAdapter() {
//		 	public void componentDraged(java.awt.event.ComponentEvent e) {
//		 		// --Warning! System.out.println("componentDraged"); // TODO Auto-generated Event stub componentMoved()
//		 		thisResized(null);
//		 	}
//		 });
		 this.validate();
	}

	protected void addButtons( DirectorPanel directorPanel ){
		
		 // JToolBar中加入 JToggleButton的问题是显示很小。
		 //this.setLayout(new FlowLayout());
		 //this.addSeparator();
		 j20 = new JToggleButton("AAAAA");
		 j20.setText("AAAAA");
		 //j20.setIcon( new ImageIcon(MainFrame.pic_exit) );
//		 j20.setAction( getShowToolBarAction() );
		 //j20.setBorder(new BevelBorder(BevelBorder.RAISED));
		 //this.add(j20);
//
		 //this.addSeparator();
		 j21 = new JToggleButton("Status",new ImageIcon(MainFrame.pic_exit) );
		 //j21.setText("Status");
		 //j21.setIcon( new ImageIcon(MainFrame.pic_exit) );
		 //j21.setAction( getShowStatusBarAction() );
		 j21.addActionListener(directorPanel);
		 //j21.setBorder(new BevelBorder(BevelBorder.RAISED));
		 //this.add(j21);
		 
		 j20.setBorder(new BevelBorder(BevelBorder.RAISED));
		 j20.setToolTipText("退出系统");
//		 j20.addActionListener(directorPanel);
		 
		 tb_fileExplorer = this.add(new ButtonAction(MainFrame.pic_fileExplorer));
		 tb_fileExplorer.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_fileExplorer.setToolTipText("File Explorer");
		 tb_fileExplorer.addActionListener( directorPanel );
		 tb_fileCopy = this.add(new ButtonAction(MainFrame.pic_fileCopy));
		 tb_fileCopy.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_fileCopy.setToolTipText("File Copy");
		 tb_fileCopy.addActionListener( directorPanel );
		 tb_favoriteFile = this.add(new ButtonAction(MainFrame.pic_favoriteFile));
		 tb_favoriteFile.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_favoriteFile.setToolTipText("Favorite File");
		 tb_favoriteFile.addActionListener( directorPanel );

		 this.addSeparator();
		 
		 tb_documentLibrary = this.add(new ButtonAction(MainFrame.pic_documentLibrary));
		 tb_documentLibrary.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_documentLibrary.setToolTipText("Document Library");
		 tb_documentLibrary.addActionListener( directorPanel );
		 tb_programLibrary = this.add(new ButtonAction(MainFrame.pic_programLibrary));
		 tb_programLibrary.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_programLibrary.setToolTipText("Program Library");
		 tb_programLibrary.addActionListener( directorPanel );
		 
//		 this.addSeparator();

		 tb_exitSys = this.add(new ButtonAction(MainFrame.pic_exit));
		 tb_exitSys.setBorder(new BevelBorder(BevelBorder.RAISED));
		 tb_exitSys.setToolTipText("退出系统");
		 tb_exitSys.addActionListener(directorPanel);
		 tb_exitSys.setVisible(false);
			
	}


	// 工具条
	//  JToolBar jtb_Tool = new JToolBar("工具集");  // 工具栏	
	public JButton tb_creatAwoke = null; // 工具栏按钮-新建	
	public JButton tb_modAwoke = null; // 工具栏按钮-修改
	public JButton tb_fileExplorer = null;  
	public JButton tb_fileCopy = null; 
	public JButton tb_favoriteFile = null;
	public JButton tb_documentLibrary = null; 
	public JButton tb_programLibrary = null;
	public JButton tb_exitSys = null; // 工具栏按钮-完整性检查	 
	
	public JButton tb_creatNote = null; // 工具栏按钮-新建	
	
	public JToggleButton j20 = null;
	public JToggleButton j21 = null;
	 

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * <p>java method describe</p>
	 * @author Zeven on 2011-4-8
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
	@Override
	public void update(Observable o, Object arg) {
		
	}

}
